<%--
  Created by IntelliJ IDEA.
  User: cc
  Date: 2020/10/2
  Time: 10:49
  To change this template use File | Settings | File Templates.
--%>
<%@ page import="com.media.bean.UserBean" %>
<%@ page import="java.sql.DriverManager" %>
<%@ page import="java.sql.Statement" %>
<%@ page import="java.sql.Connection" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<jsp:useBean id="user" class="com.media.bean.UserBean"></jsp:useBean>
<jsp:setProperty name="user" property="*"></jsp:setProperty>

<%
    Class.forName("com.mysql.jdbc.Driver");

    String url ="jdbc:mysql://localhost:3306/book";
    Connection connection = DriverManager.getConnection(url,"root","root");

    Statement stmt = connection.createStatement();

    String sqL = "insert into user(username,password,gender , age) values ('" +user . getUsername()+"','"+user . getPassword()+"',1,22)";
    //String sqL ="update user set status = 3 where id = 12";
    //String sql = "delete from user where id = 12";

    int count = stmt.executeUpdate (sqL);

    if(count > 0){
        out . print("注册成功");
    }else{
        out. print("注册失败");
    }
%>


